{include file="public/layout"/}
<body data-type="generalComponents">
<div class="tpl-content-wrapper js-check-wrap">
    <ol class="am-breadcrumb">
        <li><a href="javascript:void(0)" onclick="javascript:parent.openItem('welcome|Index');" class="am-icon-home">首页</a></li>
        <li class="am-active">会员</li>
        <li class="am-active">会员列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="tpl-block">
            <form method="post">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-6">&nbsp;</div>
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" class="am-form-field" name="keywords" id="keywords" value="{$keyword ?? ''}" placeholder="手机或者邮箱">
                            <span class="am-input-group-btn">
                                <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="button" id="search"></button>
                            </span>
                        </div>
                    </div>
                </div>
            </form>
            <form class="js-ajax-form" method="post" id="search-form2">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                {$action|actionList|raw}
                            </div>
                            <div class="refresh am-vertical-align-middle">
                                <div class="refresh_tit" title="刷新数据"><i class="am-icon-refresh"></i></div>
                                <div class="refresh_span">刷新 - 共<span id="count">0</span>条记录</div>
                            </div>
                        </div>
                    </div>
                </div>
                <input type="hidden" name="act" value="del">
                <div class="am-g">
                    <div class="am-u-sm-12">
                        <table class="am-table am-table-striped am-table-hover table-main" id="user-table">
                            <thead>
                                <tr>
                                    <th class="table-check"><input type="checkbox" class="tpl-table-fz-check js-check-all" data-direction="x" data-checklist="js-check-x"></th>
                                    <th class="table-id">ID</th>
                                    <th class="table-title">会员昵称</th>
                                    <th class="table-type">会员等级</th>
                                    <th class="table-author am-hide-sm-only">累计消费</th>
                                    <th class="table-date am-hide-sm-only">邮件地址</th>
                                    <th class="table-date am-hide-sm-only">手机号码</th>
                                    <th class="table-date am-hide-sm-only">余额</th>
                                    <th class="table-date am-hide-sm-only">积分</th>
                                    <th class="table-date am-hide-sm-only">注册时间</th>
                                    <th class="table-set">操作</th>
                                </tr>
                            </thead>
                            <tbody id="ajax_return"></tbody>
                        </table>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    $(function(){
        var table = $('#user-table').DataTable({
            processing: true, //隐藏加载提示,自行处理
            bProcessing:true, //使用ajax源
            serverSide: true, //使用服务器端分页
            "searching":false,
            "info":     false,
            bLengthChange: false,   //去掉每页显示多少条数据方法
            "iDisplayLength": 20,   //默认显示20条
            ajax: {
                "url":"{:url('user/ajaxindex')}",
                "data":function(d){    //额外传递的参数
                    d.keywords = $('#keywords').val();
                }
            },
            createdRow: function ( row, data, index ) {
                $(row).addClass('text-c');
                $('#count').html(data.recordsFiltered);
            },
            aoColumns: [
                {
                    "sClass": "text-center",
                    "data": "user_id",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox" class="js-check"  data-yid="js-check-y" data-xid="js-check-x"  name="user_id"  value="' + data + '" />';
                    },
                    "bSortable": false
                },
                { "mData": "user_id" },
                { "mData": "nickname"},
                { "mData": "level_name" },
                { "mData": "total_amount" },
                { "mData": function(data){
                        return data.email+data.email_status
                    }
                },
                { "mData": function(data){
                        return data.mobile+data.mobile_status
                    }
                },
                { "mData": "user_money"},
                { "mData": "pay_points"},
                { "mData": "reg_time"},
                {
                    "sClass": "text-center",
                    "data": "id",
                    "render": function (data, type, full, meta) {
                        html = '<div class="am-btn-toolbar">';
                        html +='<div class="am-btn-group am-btn-group-xs">',
                        html +='<a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="{:url('admin/admin_info')}"><i class="am-icon-pencil-square-o"></i> 编辑</a>';
                        html +='<a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only js-ajax-delete" href="{:url('user/delete')}" data-msg="确定要删除吗？"><i class="am-icon-trash-o"></i> 删除</a>';
                        html +='</div>';
                        html +='</div>';
                        return html;
                    },
                    "bSortable": false
                }
            ],
            columnDefs : [
                {
                    targets : 0,
                    "orderable" : false
                },{
                    targets :2,
                    "orderable" : false
                },{
                    targets :3,
                    "orderable" : false
                },{
                    targets :5,
                    "orderable" : false
                },{
                    targets :6,
                    "orderable" : false
                },{
                    targets :10,
                    "orderable" : false
                }
            ],
            "order" : [ [ 1, 'desc' ] ],
            //重绘回调函数
            fnDrawCallback: function () {
                createScript();
            }
        });
        $('#search').click(function() {
            table.draw();
        })
    })

    function createScript() {
        var oHead = document.getElementsByTagName('HEAD').item(0);
        var oScript= document.createElement("script");
        oScript.type = "text/javascript";
        oScript.src="__ADMIN__/js/admin.js";
        oHead.appendChild( oScript);
    }
</script>
</body>
</html>